package cn.edu.cug.cs.gtl.apis.render;

import cn.edu.cug.cs.gtl.apis.render.nodes.Node;
import cn.edu.cug.cs.gtl.common.Pair;
import cn.edu.cug.cs.gtl.protos.*;
import cn.edu.cug.cs.gtl.apis.render.viewers.Viewer;
import com.google.protobuf.InvalidProtocolBufferException;

import java.io.IOException;

public interface Render {

    void setProject(Project project);

    Project getProject();

    Node getSceneGraph();

    void setSceneGraph(Node sceneGraph);

    Node readSceneGraph(String fileName) throws IOException ;

    Viewer getViewer();

    void setViewer(Viewer viewer);

    void removeMapNode(Map map);

    void removeLayerNode(Layer layer);


    void setVisible(Project project , boolean visible);

    void setVisible(Map map , boolean visible);

    void setVisible(Layer layer , boolean visible);


     Pair<Node,Node> findNode(Project project);

    Pair<Node,Node> findNode(Map map);

    Pair<Node,Node> findNode(Layer layer);

    Node removeNode(Project project);

    Node removeNode(Map map);

    Node removeNode(Layer layer);
    static String nodeName(Project project){
        return "Project";
    }
    static String nodeName(Map map){
        return "MAP-"
                +Long.valueOf(map.getIdentifier().getExtent()).toString()
                +"-"
                +Long.valueOf(map.getIdentifier().getData()).toString();
    }
    static String nodeName(Layer layer){
        return "LAYER-"
                +Long.valueOf(layer.getIdentifier().getExtent()).toString()
                +"-"
                +Long.valueOf(layer.getIdentifier().getData()).toString();
    }
    static String nodeName(Geometry geometry){
        return "GEOMETRY-"
                +Long.valueOf(geometry.getIdentifier().getExtent()).toString()
                +"-"
                +Long.valueOf(geometry.getIdentifier().getData()).toString();
    }
    Node createProjectNode(Project project);

    Node createMapNode(Map map) ;

    Node createLayerNode(Layer layer) ;
    Node createGeometryNode(Geometry geometry) throws InvalidProtocolBufferException;
}
